package com.lazy.book.common.listener;


import com.lazy.book.common.utils.SpringApplicationContextUtils;
import io.lettuce.core.support.caching.RedisCache;

import static com.lazy.book.common.enums.DynamicDictEnum.DYNAMIC_USER_OPTIONS;

/**
 * <p>sys_user监听器</p>
 *
 * @author lazy
 * @since 2025-09-04
 */
public class TableSysUserListener  extends EntityChangeListener{
  @Override
  public void onInsert(Object o) {
    super.onInsert(o);
    onChange(o);
  }

  @Override
  public void onUpdate(Object o) {
    super.onUpdate(o);
    onChange(o);
  }

  /**
   * 触发change事件
   *
   * @param o
   *            对象
   */
  private void onChange(Object o) {
    RedisCache cache = SpringApplicationContextUtils.getInstance().getBean(RedisCache.class);
    cache.clearDict(DYNAMIC_USER_OPTIONS.getTypeCode());
  }
}
